HAL RAMCFG initialization and configuration functions migration ¶
The goal of this page is to show how to migrate the initialization sequence using STM32CubeMX2:
Open STM32CubeMX2 RAMCFG configuration panel.
Configure the SW layer HAL.
Configure the RAMCFG main features.
Configure the advanced RAMCFG features.
Configure the NVIC if the application requires the RAMCFG to be used in IT mode.
Generate the code.
HAL RAMCFG configuration panel ¶
Create a new project with the STM32CubeMX2, then start the initialization and the main configuration.
HAL RAMCFG advanced features configuration ¶
Configure the advanced RAMCFG features if needed.
NVIC configuration ¶
Configure the NVIC in case of an interrupt.
Generated RAMCFG initialization and de-initialization sequences ¶
The RAMCFG initialization and de-initialization sequences are generated in the
mx_ramcfg_hal_init
function in
mx_ramcfg.c
file under
$YOUR_PROJECT_NAME$/$YOUR_PROJECT_NAME$_SW/generated/STM32Cube_CodeGen.
Related concepts:
|
Topic |
HAL1 code snippet |
HAL2 code snippet |
|---|---|---|
|
Initialization and configuration sequence |
static void MX_RAMCFG_Init(void)
{
/** Initialize RAMCFG BKPRAM */
hramcfg_BKPRAM.Instance = RAMCFG_BKPRAM;
if (HAL_RAMCFG_Init(&hramcfg_BKPRAM) != HAL_OK)
{
Error_Handler();
}
if (HAL_RAMCFG_StartECC(&hramcfg_BKPRAM) != HAL_OK)
{
Error_Handler();
}
}
void HAL_RAMCFG_MspInit(RAMCFG_HandleTypeDef* hramcfg)
{
/* Peripheral clock enable */
__HAL_RCC_RAMCFG_CLK_ENABLE();
/* RAMCFG interrupt Init */
HAL_NVIC_SetPriority(RAMCFG_IRQn, 0, 0);
HAL_NVIC_EnableIRQ(RAMCFG_IRQn);
}
|
hal_ramcfg_t mx_ramcfg_sram2_init(void)
{
HAL_RCC_RAMCFG_EnableClock();
/* Enable the interruption for RAMCFG */
HAL_CORTEX_NVIC_SetPriority(RAMCFG_IRQn, HAL_CORTEX_NVIC_PREEMP_PRIORITY_0, HAL_CORTEX_NVIC_SUB_PRIORITY_0);
HAL_CORTEX_NVIC_EnableIRQ(RAMCFG_IRQn);
HAL_RAMCFG_ECC_Enable_IT(HAL_RAMCFG_SRAM2, HAL_RAMCFG_IT_ECC_DOUBLE);
return HAL_RAMCFG_SRAM2;
}
|
|
Deinitialization sequence |
static void Ramcfg_deinit(void)
{
if (HAL_RAMCFG_DeInit(&hramcfg1) != HAL_OK)
{
Error_Handler();
}
}
void HAL_RAMCFG_MspDeInit(RAMCFG_HandleTypeDef* hramcfg)
{
/* Peripheral clock disable */
__HAL_RCC_RAMCFG_CLK_DISABLE();
/* RAMCFG interrupt DeInit */
HAL_NVIC_DisableIRQ(RAMCFG_IRQn);
}
|
void mx_ramcfg_sram2_deinit(void)
{
HAL_RAMCFG_ECC_Disable(HAL_RAMCFG_SRAM2);
}
|
|
IRQ handle function |
void RAMCFG_IRQHandler(void)
{
HAL_RAMCFG_IRQHandler(&hramcfg_BKPRAM);
}
|
void RAMCFG_BKPRAM_IRQHandler(void)
{
HAL_RAMCFG_IRQHandler(HAL_RAMCFG_SRAM2);
}
|